Media Categories

Remember instance an object of FouryouseeAPI, according to the basic set up

Getting the media categories

fouryousee.FouryouseeAPI.get_media_category(self, **kwargs)

Get the media categories of the 4YouSee account.

Parameters

id (int, optional) – Id of the media category.

Returns

List of dicts, where every dict, depicts a media category.

Return type

list

Usage

Once “my” object has been created. You can execute the next:

Getting all media categories. It will return all the media categories of your account. It will be a list of dicts. If there is no media category will return a empty list.

>>> my.get_media_category()

If you know the media category id

>>> my.get_media_category(id=108)
{
   "id":108,
   "name":"sample media category",
   "description":"None",
   "parent":{
      "id":1,
      "name":"DEMO",
      "description":"",
      "carouselThumbnail":"None",
      "autoShuffle":false,
      "updateFlow":"1"
   },
   "children":[ ],
   "carouselThumbnail":"None",
   "autoShuffle":false,
   "updateFlow":"1",
   "sequence":[ ]
}

If the id doesn’t exists.

>>> my.get_media_category(id=123_456)
Exception: {"message":"Category with ID 123456 was not found"}

Advanced usage

  • Getting empty media categories.

>>> my.get_media_category()
>>> [ mc['id'] for mc in my.media_category if not len(mc['sequence'])]
[9, 10, 14, 17, 18, 19, 20,]

Adding media categories

fouryousee.FouryouseeAPI.add_media_category(self, **kwargs) dict

Create a new category in the 4yousee account library.

Parameters
  • name (str, required) – Category/subcategory display name.

  • description (str, optional) – Detailed category description.

  • parent (int, optional) – When informed it creates a subcategory.

  • autoShuffle (bool, optional .) – True to scramble the order of contents on the carousel.

  • updateFlow (int, optional) – 1 to restart carousel after carousel update; 2: Do not restart after carousel update.

Returns

Dict that depicts the media category created.

Return type

dict

Usage

Once “my” object has been created. You can execute the next:

Passing only the required params

>>> my.add_media_category(name='Example category')
{
  "id": 29,
  "name": "sample category",
  "description": null,
  "parent": null,
  "children": [],
  "carouselThumbnail": null,
  "autoShuffle": false,
  "updateFlow": "1",
  "sequence": null
}

Adding a subcategory

>>> my.add_media_category(name='New category',
...                       description='Son of category #143',
...                       parent=143, autoShuffle=True)
{
    'id': 29,
    'name': 'New category',
    'description': 'Son of category #143',
    'parent':
        {
            'id': 30,
            'name': 'Example category',
            'description': None,
            'carouselThumbnail': None,
            'autoShuffle': False,
            'updateFlow': '1'
        },
    'children': [],
    'carouselThumbnail': None,
    'autoShuffle': True,
    'updateFlow': '1',
    'sequence': None
}

Adding a category that when is being update, It wont restart his execution inmediately

>>> my.add_media_category(name='New category', updateFlow=2)
{
    'id': 31,
    'name': 'New category',
    'description': None,
    'parent': None,
    'children': [],
    'carouselThumbnail': None,
    'autoShuffle': False,
    'updateFlow': '2',
    'sequence': None
}

Editing medias categories

fouryousee.FouryouseeAPI.edit_category(self, **kwargs)

It is possible update name, description and/or parent of category.

Parameters
  • name (str, optional) – Id of the media category to be edited.

  • name – Category/subcategory display name.

  • description (str, optional) – Detailed category description.

  • parent (int, optional) – When present it convert category in subcategory of category informed parent. If the value is null, it converts the subcategory into a first level category.

Returns

Dict that depicts the modified media.

Return type

dict

Usage

Once “my” object has been created. You can execute the next:

Changing the name and description.

>>> my.edit_category(id=52, name='Category #52', description='Info of category #52')
{
  "id": 52,
  "name": "Category #52",
  "description": "Info of category #52",
  "parent": null,
  "children": [],
  "carouselThumbnail": null,
  "autoShuffle": false,
  "updateFlow": "1",
  "sequence": []
}

Changing the parent

>>> my.edit_category(id=52, parent=53)
{
  "id": 52,
  "name": "Category #52",
  "description": "Info of category #52",
  "parent": {
    "id": 53,
    "name": "sample media category",
    "description": null,
    "carouselThumbnail": null,
    "autoShuffle": false,
    "updateFlow": "1"
  },
  "children": [],
  "carouselThumbnail": null,
  "autoShuffle": false,
  "updateFlow": "1",
  "sequence": []
}

Editing multiple medias categories

fouryousee.FouryouseeAPI.edit_multiple_categories(self, *args)

Update bulk category. It is possible to update name, description, parent and sequence for multiple categories. You can pass more than one dict with the next params

Parameters
  • name (str, optional) – Category display name.

  • name – Category display name.

  • description (str, optional) – Detailed category description.

  • parent (int or null, optional) – When present it convert category in subcategory of category informed parent. If the value is null, it converts the subcategory into a first level category.

  • sequence (list[int], optional) – This array must contain all content ids associated to each category in each item. The order of these ids in the array is the order they will appear in the carousel

Returns

Dict that depicts the media categories edited

Return type

dict

*Usage

Once “my” object has been created. You can execute the next:

Changing name, description, parent and sequence

>>> my.edit_multiple_categories({
...                                 "id": 11,
...                                 "name": "Category #11",
...                                 "description": "Description for category 11",
...                                 "parent": 10,
...                                 "sequence": [ 99, 1, 230 ]
...                             },
...                             {
...                                 "id": 12,
...                                 "name": "Category #12",
...                                 "description": "Description for category 12",
...                                 "sequence": [ 99, 230 ]
...                             })
{
  "carouselItems": [
    {
      "id": 11,
      "name": "Category #11",
      "description": "Description for category 11",
      "parent": {
        "id": 10,
        "name": "Proveedor X",
        "description": "",
        "carouselThumbnail": null,
        "autoShuffle": false,
        "updateFlow": "1"
      },
      "children": [],
      "carouselThumbnail": null,
      "autoShuffle": false,
      "updateFlow": "1",
      "sequence": [ 99, 1, 230 ]
    },
    {
      "id": 12,
      "name": "Category #12",
      "description": "Description for category 12",
      "parent": {
        "id": 10,
        "name": "Proveedor X",
        "description": "",
        "carouselThumbnail": null,
        "autoShuffle": false,
        "updateFlow": "1"
      },
      "children": [],
      "carouselThumbnail": null,
      "autoShuffle": false,
      "updateFlow": "1",
      "sequence": [ 99, 230 ]
    }
  ]
}

Deleting medias categories

Warning

At the moment of the building of this documentation, the 4YouSee API doesn’t have the endpoint for deleting media categories.